package com.sjk.flink.correct.rules;

import com.sjk.flink.correct.IfCorrectRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 数字校准
 *
 */
public class IntegerRuler implements IfCorrectRule {

    private static final Logger log = LoggerFactory.getLogger(IntegerRuler.class);

    @Override
    public String getName() {
        return "Integer";
    }

    @Override
    public Object transformValue(Object val) {
        if(val!=null) {
            try {
                return Integer.parseInt(val.toString());
            }catch (Exception ex){
                ex.printStackTrace();
            }
        }
        return val;
    }

    public static void main(String[] args) {
        IntegerRuler ruler = new IntegerRuler();
        System.out.println(ruler.transformValue(""));
        System.out.println(ruler.transformValue("1"));
        System.out.println(ruler.transformValue("A"));
        System.out.println(ruler.transformValue("\"\""));
    }

}
